package com.sqx.modules.health.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqx.modules.health.entity.Busdict;
import com.sqx.modules.health.mapper.BusdictMapper;
import com.sqx.modules.health.service.IBusdictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 业务字典表 服务实现类
 * </p>
 *
 * @author hsx
 * @since 2022-08-30
 */
@Service
public class BusdictServiceImpl extends ServiceImpl<BusdictMapper, Busdict> implements IBusdictService {
    @Autowired
    private IBusdictService busdictService;
    @Override
    public List getViewList(Map<String, String> params) {
        QueryWrapper<Busdict> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(ObjectUtil.isNotEmpty(params.get("level")), "level", params.get("level"))
                .in(ObjectUtil.isNotEmpty(params.get("ids")), "id", params.get("ids"))
                .eq(ObjectUtil.isNotEmpty(params.get("type")), "type", params.get("type"))
                .eq(ObjectUtil.isNotEmpty(params.get("pid")), "pid", params.get("pid"))
                .eq( "status", 1)
                .like(ObjectUtil.isNotEmpty(params.get("name")), "name", params.get("name"))
                .orderByDesc("id");
       List busDict =  busdictService.list(queryWrapper);
        List viewDict = new ArrayList<>();
//        if(busDict.size()>0){
//               for(int i=0;i<busDict.size();i++){
//                   Busdict one = (Busdict) busDict.get(i);
//                   one.getId();
//                   one.getId()+"-"+one.getName()
//                   one.getValue();
//
//                       JSONObject json= new JSONObject();
//                       json.put("id",Integer.valueOf(item.split("-")[0]));
//                       json.put("name",item);
//                       json.put("value",item.split("-")[1]);
//
//                   }
//                   viewDict.add();
//               }
//        }

        return null;
    }

}
